package com.apetrenko.avaya.callstore.client;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Hyperlink;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

public class ManagerPane extends Composite {

	private class MgrTopPanel extends Composite {

		private VerticalPanel iPanel = new VerticalPanel();
		private HorizontalPanel iUpperPanel = new HorizontalPanel();
		private HorizontalPanel iLowerPanel = new HorizontalPanel();

		public MgrTopPanel() {
			iUpperPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT);

			iUpperPanel.setStyleName("yapm-top-upper");

			iLowerPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
			iLowerPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);

			HTML vCaption = new HTML("<b>Система управления услугами</b>");
			vCaption.setStyleName("yapm-top-lower-caption");

			iLowerPanel.add(vCaption);
			iLowerPanel.setStyleName("yapm-top-lower");
			
			iUpperPanel.add(new Hyperlink("Log Out", "logout"));

			iPanel.add(iUpperPanel);
			iPanel.add(iLowerPanel);
			iPanel.setWidth("100%");

			initWidget(iPanel);

			this.setWidth("100%");
			this.setHeight("25px");			
		}

	}

	private DockPanel iOuter = new DockPanel();
	private CenterPanel iCenterPanel = new CenterPanel();
	private LeftPanel iLeftPanel = new LeftPanel();

	public ManagerPane() {
		iCenterPanel.setWidth("100%");

		iOuter.add(new MgrTopPanel(), DockPanel.NORTH);
		iOuter.add(iLeftPanel, DockPanel.WEST);
		iOuter.add(iCenterPanel, DockPanel.CENTER);

		iOuter.setWidth("100%");

		iOuter.setSpacing(4);
		iOuter.setCellWidth(iCenterPanel, "100%");
		initWidget(iOuter);
		
		setCenterPanel(new RecordsPanel());
	}

	public void clearCenterPanel() {
		iCenterPanel.clear();
	}

	public void setCenterPanel(Widget aWidget) {
		iCenterPanel.setWidget(aWidget);
	}

}
